package org.obm.mina;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Blob {

	private File file;
	private String path;

	protected Blob(final File file) {
		if (file == null)
			throw new NullPointerException("file cannot be null");

		this.file = file;
		this.path = file.getAbsolutePath();
	}

	public File getFile() {
		return file;
	}

	public InputStream getInputStream() throws IOException {
		InputStream in = new FileInputStream(file);
		return in;
	}

	/**
	 * Returns the size of the blob's data.
	 */
	public long getRawSize() {
		return file.length();
	}

	@Override
	public String toString() {
		return "Blob: { path=" + path + ", size=" + getRawSize() + " }";
	}
}
